import React, { FC, useState } from "react";
import { getLocale, localeInfo } from "@@/plugin-locale/localeExports"
import { useMount } from "ahooks";
import { event, LANG_CHANGE_EVENT } from "@/.umi/plugin-locale/locale";
const ErrorIntal: FC<{ id: string }> = (props) => {
    const [lang, setLang] = useState(getLocale())
    useMount(() => {
        event.on(LANG_CHANGE_EVENT, ($lang: string) => {
            setLang($lang)
        })
    })
    return <>{(localeInfo[lang]?.messages || {})[props.id] || props.id}</>
}
export default ErrorIntal